<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<TITLE>80386 Programmer's Reference Manual -- Opcode VERR</TITLE>
</HEAD>
<BODY STYLE="width:80ch">
<B>up:</B> <A HREF="c17.htm">
Chapter 17 -- 80386 Instruction Set</A><BR>
<B>prev:</B><A HREF="TEST.htm"> TEST Logical Compare</A><BR>
<B>next:</B><A HREF="WAIT.htm"> WAIT Wait until BUSY# Pin is Inactive (HIGH)</A>
<P>
<HR>
<P>
<H1>VERR, VERW -- Verify a Segment for Reading or Writing</H1>

<PRE>
Opcode       Instruction   Clocks      Description

0F  00 /4    VERR r/m16    pm=10/11    Set ZF=1 if segment can be read,
                                       selector in r/m16
0F  00 /5    VERW r/m16    pm=15/16    Set ZF=1 if segment can be written,
                                       selector in r/m16
</PRE>


<H2>Operation</H2>

<PRE>
IF segment with selector at (r/m) is accessible
   with current protection level
   AND ((segment is readable for VERR) OR
      (segment is writable for VERW))
THEN ZF := 0;
ELSE ZF := 1;
FI;
</PRE>

<H2>Description</H2>

The two-byte register or memory operand of VERR and VERW contains
the value of a selector. VERR and VERW determine whether the
segment denoted by the selector is reachable from the current privilege
level and whether the segment is readable (VERR) or writable (VERW).
If the segment is accessible, the zero flag is set to 1; if the segment is
not accessible, the zero flag is set to 0. To set ZF, the following
conditions must be met:
<UL>
 <LI> The selector must denote a descriptor within the bounds of the table
     (GDT or LDT); the selector must be "defined."

 <LI> The selector must denote the descriptor of a code or data segment
     (not that of a task state segment, LDT, or a gate).

 <LI> For VERR, the segment must be readable. For VERW, the segment
     must be a writable data segment.

 <LI> If the code segment is readable and conforming, the descriptor
     privilege level (DPL) can be any value for VERR. Otherwise, the
     DPL must be greater than or equal to (have less or the same
     privilege as) both the current privilege level and the selector's RPL.
</UL>

The validation performed is the same as if the segment were loaded into
DS, ES, FS, or GS, and the indicated access (read or write) were
performed. The zero flag receives the result of the validation. The
selector's value cannot result in a protection exception, enabling the
software to anticipate possible segment access problems.

<H2>Flags Affected</H2>

ZF as described above

<H2>Protected Mode Exceptions</H2>

Faults generated by illegal addressing of the memory operand that
contains the selector, the selector is not loaded into any segment
register, and no faults attributable to the selector operand are generated
<P>
#GP(0) for an illegal memory operand effective address in the CS, DS,
ES, FS, or GS segments; #SS(0) for an illegal address in the SS segment;
#PF(fault-code) for a page fault

<H2>Real Address Mode Exceptions</H2>

Interrupt 6; VERR and VERW are not recognized in Real Address Mode

<H2>Virtual 8086 Mode Exceptions</H2>

Same exceptions as in Real Address Mode; #PF(fault-code) for a page
fault


<P>
<HR>
<P>
<B>up:</B> <A HREF="c17.htm">
Chapter 17 -- 80386 Instruction Set</A><BR>
<B>prev:</B><A HREF="TEST.htm"> TEST Logical Compare</A><BR>
<B>next:</B><A HREF="WAIT.htm"> WAIT Wait until BUSY# Pin is Inactive (HIGH)</A>
</BODY>
